/*     */ package nc.impl.pu.m20;
/*     */ 
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashSet;
/*     */ import java.util.List;
/*     */ import java.util.Set;
/*     */ import nc.bs.framework.common.NCLocator;
/*     */ import nc.bs.pu.m20.maintain.PraybillQueryBP;
/*     */ import nc.bs.pu.m20.maintain.rule.pub.ChangeRateRule;
/*     */ import nc.bs.pu.m20.maintain.rule.pub.SetPraytypeRule;
/*     */ import nc.bs.pu.m20.maintain.rule.pub.SetPsnAndDeptRule;
/*     */ import nc.bs.pu.m20.maintain.rule.pub.SetSctypeRule;
/*     */ import nc.impl.pu.m20.action.PraybillCloseAction;
/*     */ import nc.impl.pu.m20.action.PraybillDeleteAction;
/*     */ import nc.impl.pu.m20.action.PraybillImportSaveAction;
/*     */ import nc.impl.pu.m20.action.PraybillInsertAction;
/*     */ import nc.impl.pu.m20.action.PraybillUpdateAction;
/*     */ import nc.impl.pubapp.pattern.data.bill.tool.BillTransferTool;
/*     */ import nc.itf.pu.m20.IPraybillMaintain;
/*     */ import nc.ui.querytemplate.querytree.IQueryScheme;
/*     */ import nc.vo.pu.m20.entity.PraybillItemVO;
/*     */ import nc.vo.pu.m20.entity.PraybillVO;
/*     */ import nc.vo.pu.m20.rule.BDirectRule;
/*     */ import nc.vo.pu.m20.rule.CalculateDateRule;
/*     */ import nc.vo.pu.m20.rule.CalculateNumRule;
/*     */ import nc.vo.pu.m20.rule.SetAstunitRule;
/*     */ import nc.vo.pu.m20.rule.SetDefaultValueRule;
/*     */ import nc.vo.pu.m20.rule.SetEmployeeRule;
/*     */ import nc.vo.pu.m20.rule.SetOrdertrantypeRule;
/*     */ import nc.vo.pu.m20.rule.SetOrgCurrRule;
/*     */ import nc.vo.pu.m20.rule.SetOrgNewVersionRule;
/*     */ import nc.vo.pu.m20.rule.SetPriceRule;
/*     */ import nc.vo.pu.m20.rule.SetPurchaseorgRule;
/*     */ import nc.vo.pub.BusinessException;
/*     */ import nc.vo.pub.lang.UFDouble;
/*     */ import nc.vo.pubapp.pattern.exception.ExceptionUtils;
/*     */ import nccloud.commons.lang.ArrayUtils;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class PraybillMaintainImpl
/*     */   implements IPraybillMaintain
/*     */ {
/*     */   public PraybillVO[] closeBill(PraybillVO[] Vos) throws BusinessException {
/*     */     try {
/*  62 */       BillTransferTool<PraybillVO> tool = new BillTransferTool<PraybillVO>(Vos);
/*  63 */       PraybillVO[] fullVOs = (PraybillVO[])tool.getClientFullInfoBill();
/*     */ 
/*     */       
/*  66 */       PraybillVO[] returnVOs = ((IPraybillMaintain)NCLocator.getInstance().lookup(IPraybillMaintain.class)).closeBillByFullVO(fullVOs);
/*  67 */       return (PraybillVO[])tool.getBillForToClient(returnVOs);
/*     */     }
/*  69 */     catch (Exception e) {
/*  70 */       ExceptionUtils.marsh(e);
/*     */ 
/*     */       
/*  73 */       return null;
/*     */     } 
/*     */   }
/*     */ 
/*     */   
/*     */   public PraybillVO[] closeBillByFullVO(PraybillVO[] Vos) throws BusinessException {
/*     */     try {
/*  80 */       return (new PraybillCloseAction()).closeBill(Vos);
/*     */     
/*     */     }
/*  83 */     catch (Exception e) {
/*  84 */       ExceptionUtils.marsh(e);
/*     */ 
/*     */       
/*  87 */       return null;
/*     */     } 
/*     */   }
/*     */ 
/*     */   
/*     */   public PraybillVO[] closeBillRow(PraybillVO[] Vos) throws BusinessException {
/*     */     try {
/*  94 */       Set<String> closePks = new HashSet<String>();
/*  95 */       for (PraybillVO vo : Vos) {
/*  96 */         for (PraybillItemVO itemVo : vo.getBVO()) {
/*  97 */           closePks.add(itemVo.getPk_praybill_b());
/*     */         }
/*     */       } 
/*     */ 
/*     */ 
/*     */       
/* 103 */       BillTransferTool<PraybillVO> tool = new BillTransferTool<PraybillVO>(Vos);
/* 104 */       PraybillVO[] fullVOs = (PraybillVO[])tool.getClientFullInfoBill();
/*     */ 
/*     */       
/* 107 */       PraybillVO[] returnVOs = ((IPraybillMaintain)NCLocator.getInstance().lookup(IPraybillMaintain.class)).closeBillRowByFullVO(fullVOs, closePks);
/* 108 */       return (PraybillVO[])tool.getBillForToClient(returnVOs);
/*     */     }
/* 110 */     catch (Exception e) {
/* 111 */       ExceptionUtils.marsh(e);
/*     */ 
/*     */       
/* 114 */       return null;
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public PraybillVO[] closeBillRowByFullVO(PraybillVO[] Vos, Set<String> closePks) throws BusinessException {
/*     */     try {
/* 122 */       return (new PraybillCloseAction()).closeBillRow(Vos, closePks);
/*     */     
/*     */     }
/* 125 */     catch (Exception e) {
/* 126 */       ExceptionUtils.marsh(e);
/*     */ 
/*     */       
/* 129 */       return null;
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public void delete(PraybillVO[] Vos) throws BusinessException {
/*     */     try {
/* 140 */       (new PraybillDeleteAction()).delete(Vos);
/*     */     }
/* 142 */     catch (Exception e) {
/* 143 */       ExceptionUtils.marsh(e);
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public PraybillVO[] insert(PraybillVO[] Vos) throws BusinessException {
/* 155 */     PraybillVO[] ret = null;
/*     */     try {
/* 157 */       PraybillInsertAction action = new PraybillInsertAction();
/*     */       
/* 159 */       ret = action.insert(Vos);
/*     */     }
/* 161 */     catch (Exception ex) {
/* 162 */       ExceptionUtils.marsh(ex);
/*     */     } 
/* 164 */     return ret;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public PraybillVO[] openBill(PraybillVO[] Vos) throws BusinessException {
/*     */     try {
/* 172 */       BillTransferTool<PraybillVO> tool = new BillTransferTool<PraybillVO>(Vos);
/* 173 */       PraybillVO[] fullVOs = (PraybillVO[])tool.getClientFullInfoBill();
/*     */ 
/*     */       
/* 176 */       PraybillVO[] returnVOs = ((IPraybillMaintain)NCLocator.getInstance().lookup(IPraybillMaintain.class)).openBillByFullVO(fullVOs);
/* 177 */       return (PraybillVO[])tool.getBillForToClient(returnVOs);
/*     */     }
/* 179 */     catch (Exception e) {
/* 180 */       ExceptionUtils.marsh(e);
/*     */ 
/*     */       
/* 183 */       return null;
/*     */     } 
/*     */   }
/*     */ 
/*     */   
/*     */   public PraybillVO[] openBillByFullVO(PraybillVO[] Vos) throws BusinessException {
/*     */     try {
/* 190 */       return (new PraybillCloseAction()).openBill(Vos);
/*     */     
/*     */     }
/* 193 */     catch (Exception e) {
/* 194 */       ExceptionUtils.marsh(e);
/*     */ 
/*     */       
/* 197 */       return null;
/*     */     } 
/*     */   }
/*     */   
/*     */   public PraybillVO[] openBillRow(PraybillVO[] Vos) throws BusinessException {
/*     */     try {
/* 203 */       Set<String> openPks = new HashSet<String>();
/* 204 */       for (PraybillVO vo : Vos) {
/* 205 */         for (PraybillItemVO itemVo : vo.getBVO()) {
/* 206 */           openPks.add(itemVo.getPk_praybill_b());
/*     */         }
/*     */       } 
/*     */ 
/*     */ 
/*     */       
/* 212 */       BillTransferTool<PraybillVO> tool = new BillTransferTool<PraybillVO>(Vos);
/* 213 */       PraybillVO[] fullVOs = (PraybillVO[])tool.getClientFullInfoBill();
/*     */ 
/*     */       
/* 216 */       PraybillVO[] returnVOs = ((IPraybillMaintain)NCLocator.getInstance().lookup(IPraybillMaintain.class)).openBillRowByFullVO(fullVOs, openPks);
/* 217 */       return (PraybillVO[])tool.getBillForToClient(returnVOs);
/*     */     }
/* 219 */     catch (Exception e) {
/* 220 */       ExceptionUtils.marsh(e);
/*     */ 
/*     */       
/* 223 */       return null;
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public PraybillVO[] openBillRowByFullVO(PraybillVO[] Vos, Set<String> openPks) throws BusinessException {
/*     */     try {
/* 231 */       return (new PraybillCloseAction()).openBillRow(Vos, openPks);
/*     */     
/*     */     }
/* 234 */     catch (Exception e) {
/* 235 */       ExceptionUtils.marsh(e);
/*     */ 
/*     */       
/* 238 */       return null;
/*     */     } 
/*     */   }
/*     */ 
/*     */   
/*     */   public PraybillVO[] queryPrayBills(IQueryScheme queryScheme) throws BusinessException {
/*     */     try {
/* 245 */       return (new PraybillQueryBP()).query(queryScheme);
/*     */     }
/* 247 */     catch (Exception e) {
/* 248 */       ExceptionUtils.marsh(e);
/*     */       
/* 250 */       return null;
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public PraybillVO[] saveBase(PraybillVO[] Vos) throws BusinessException {
/* 260 */     PraybillVO[] savedVos = null;
/*     */     try {
/* 262 */       List<PraybillVO> insertVOList = new ArrayList<PraybillVO>();
/* 263 */       List<PraybillVO> updateVOList = new ArrayList<PraybillVO>();
/* 264 */       for (int i = 0, len = Vos.length; i < len; i++) {
/* 265 */         if (2 == Vos[i].getHVO().getStatus()) {
/* 266 */           insertVOList.add(Vos[i]);
/*     */         } else {
/* 268 */           updateVOList.add(Vos[i]);
/*     */         } 
/*     */       } 
/* 271 */       if (insertVOList.size() != 0)
/*     */       {
/* 273 */         return ((IPraybillMaintain)NCLocator.getInstance().lookup(IPraybillMaintain.class))
/* 274 */           .insert((PraybillVO[])insertVOList.toArray(new PraybillVO[insertVOList.size()]));
/*     */       }
/* 276 */       if (updateVOList.size() != 0)
/*     */       {
/* 278 */         return ((IPraybillMaintain)NCLocator.getInstance().lookup(IPraybillMaintain.class))
/* 279 */           .update((PraybillVO[])updateVOList.toArray(new PraybillVO[updateVOList.size()]));
/*     */       }
/*     */     }
/* 282 */     catch (Exception e) {
/* 283 */       ExceptionUtils.marsh(e);
/*     */     } 
/* 285 */     return savedVos;
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public PraybillVO[] setDefaultValue(PraybillVO[] vos) throws BusinessException {
/*     */     try {
/* 293 */       (new SetOrgNewVersionRule()).process(vos);
/*     */       
/* 295 */       (new BDirectRule()).process(vos);
/*     */       
/* 297 */       PraybillVO[] afterSplitVos = (new SetSctypeRule()).process(vos);
/*     */       
/* 299 */       (new SetDefaultValueRule()).process(afterSplitVos);
/*     */       
/* 301 */       (new SetOrgCurrRule()).process(afterSplitVos);
/*     */       
/* 303 */       (new SetPraytypeRule()).process(afterSplitVos);
/*     */       
/* 305 */       (new SetPsnAndDeptRule()).process(afterSplitVos);
/*     */ 
/*     */       
/* 308 */       (new SetPurchaseorgRule()).process(afterSplitVos);
/*     */       
/* 310 */       (new SetEmployeeRule()).process(afterSplitVos);
/*     */       
/* 312 */       (new SetOrdertrantypeRule()).process(afterSplitVos);
/*     */       
/* 314 */       (new SetAstunitRule()).process(afterSplitVos);
/*     */       
/* 316 */       (new ChangeRateRule()).process(afterSplitVos);
/*     */       
/* 318 */       (new CalculateNumRule()).process(afterSplitVos);
/*     */       
/* 320 */       (new CalculateDateRule()).process(afterSplitVos);
/*     */       
/* 322 */       (new SetPriceRule()).process(afterSplitVos);
/*     */       
/* 324 */       setUFDouble(afterSplitVos);
/*     */       
/* 326 */       return afterSplitVos;
/*     */     }
/* 328 */     catch (Exception e) {
/* 329 */       ExceptionUtils.marsh(e);
/*     */       
/* 331 */       return null;
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public PraybillVO[] update(PraybillVO[] Vos) throws BusinessException {
/* 341 */     PraybillVO[] ret = null;
/*     */     try {
/* 343 */       PraybillUpdateAction action = new PraybillUpdateAction();
/*     */       
/* 345 */       ret = action.update(Vos);
/*     */     }
/* 347 */     catch (Exception ex) {
/* 348 */       ExceptionUtils.marsh(ex);
/*     */     } 
/* 350 */     return ret;
/*     */   }
/*     */ 
/*     */   
/*     */   private void setUFDouble(PraybillVO[] vos) throws BusinessException {
/* 355 */     for (PraybillVO vo : vos) {
/* 356 */       PraybillItemVO[] items = vo.getBVO();
/* 357 */       if (!ArrayUtils.isEmpty(items))
/*     */       {
/*     */ 
/*     */         
/* 361 */         for (PraybillItemVO item : items) {
/* 362 */           UFDouble f = item.getNnum();
/* 363 */           if (null != f) {
/* 364 */             f = f.setScale(-8, 4);
/* 365 */             item.setNnum(f);
/*     */           } 
/*     */           
/* 368 */           f = item.getNastnum();
/* 369 */           if (null != f) {
/* 370 */             f = f.setScale(-8, 4);
/* 371 */             item.setNastnum(f);
/*     */           } 
/*     */         } 
/*     */       }
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */   
/*     */   public PraybillVO[] setDefaultValueForM4B32(PraybillVO[] vos) throws BusinessException {
/*     */     try {
/* 382 */       (new SetOrgCurrRule()).process(vos);
/*     */       
/* 384 */       (new SetPurchaseorgRule()).process(vos);
/*     */       
/* 386 */       (new SetEmployeeRule()).process(vos);
/*     */       
/* 388 */       (new SetAstunitRule()).process(vos);
/*     */       
/* 390 */       (new CalculateNumRule()).process(vos);
/*     */       
/* 392 */       (new CalculateDateRule()).process(vos);
/*     */       
/* 394 */       (new SetPriceRule()).process(vos);
/* 395 */       return vos;
/*     */     }
/* 397 */     catch (Exception e) {
/* 398 */       ExceptionUtils.marsh(e);
/*     */       
/* 400 */       return null;
/*     */     } 
/*     */   }
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public PraybillVO[] importSave(PraybillVO[] vos) throws BusinessException {
/* 409 */     PraybillImportSaveAction importSaveAction = new PraybillImportSaveAction();
/* 410 */     return importSaveAction.save(vos);
/*     */   }
/*     */ }


/* Location:              E:\zhuhai_ncc\NCC2111\modules\pu\META-INF\lib\pu_buyingreq.jar!/nc/impl/pu/m20/PraybillMaintainImpl.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.0.7
 */